<template>
  <div class="home">
    <el-row :gutter="24">
      <el-col :span="24">
        <el-menu
          :default-active="activeIndex"
          class="el-menu-demo"
          mode="horizontal"
          @select="handleSelect"
        >
          <el-menu-item index="3">高伟达加班费用报销</el-menu-item>
        </el-menu>
      </el-col></el-row>
    <el-row :gutter="24" style="margin-top: 20px">
      <el-col :span="12">
        <div class="line"></div>
        <div>
          <el-time-select
            v-model="value"
            :picker-options="{ start: '08:30', step: '00:30', end: '24:00' }"
            placeholder="选择时间"
            style="float: left"
          ></el-time-select>
          <el-upload
            class="upload-demo"
            action
            :on-change="handleChange"
            :show-file-list="false"
            :auto-upload="false"
            style="margin-left: 15px; float: left"
          >
            <el-button
              size="medium"
              type="primary"
              style="margin-bottom: 15px; float: left"
              >上传打卡记录</el-button >
          </el-upload>
        </div>
        <div class="block">
          <span class="demonstration">月</span>
          <el-date-picker
            v-model="month"
            type="month"
            format="M"
            placeholder="选择月"
            value-format="M">
          </el-date-picker>
         
        </div>
      </el-col>
      <el-col :span="8">
        <el-date-picker
            v-model="value1"
            type="daterange"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            value-format="yyyy-MM-dd"
            style="float: left;">
        </el-date-picker>
        <el-upload
          class="upload-demo"
          action
          :on-change="handleChangeOne"
          :on-remove="handleRemove"
          :before-remove="beforeRemove"
          multiple
          :limit="30"
          :on-exceed="handleExceed"
          :file-list="fileList"
          :auto-upload="false"
        >
          <el-button size="small" type="primary">上传工时表</el-button>
        </el-upload>
      </el-col>
      <el-col :span="2">  <router-link to='/a'> <el-button size="small" type="primary">查看注意事项</el-button></router-link></el-col>
      <!-- <el-col :span="2"><el-button size="small" type="primary">查看逻辑校验</el-button></el-col> -->

    </el-row>
    <el-row :gutter="24">
      <el-col :offset="1" :span="11">
        <el-table :data="tableData" size="mini" border style="width: 100%">
          <el-table-column type="index" width="50"> </el-table-column>
          <el-table-column
            prop="name"
            label="姓名"
            width="180"
            sortable
          ></el-table-column>
          <el-table-column prop="num" label="打卡天数"> </el-table-column>
        </el-table>
      </el-col>
      <el-col :offset="0" :span="12">
        <el-table :data="laterNum" size="mini" border style="width: 100%">
          <el-table-column type="index" width="50"> </el-table-column>
          <el-table-column
            prop="name"
            label="姓名"
            width="180"
            sortable
          ></el-table-column>
          <el-table-column prop="num" label="打卡天数"> </el-table-column>
        </el-table>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import XLSX from "xlsx";
import style from "../style";
import XLSXStyle from "xlsx-style";
import { getAllDate, jsono, changeWeek, daka } from "../util";
export default {
  data() {
    return {
      currentRow: null,
      value: "20:30",
      activeIndex: "",
      outList: [], //输出到excle的集合
      month: "",
      fileList: [],
      jsono: [],
      projectNum: "", //项目编号
      WorkingCycle: [], //考勤周期
      count: [],
      tableData: [], //考勤记录加班人员页面显示
      laterNum: [], //工时表加班人员天数汇总
      laterNumObj: {}, //加班人员天数累加
      value1:''
    };
  },
  created() {
    this.ccc();
  },
  computed: {
    filename: function () {
      return `${this.projectNum}#${this.month}月加班餐费明细表.xlsx`;
    },
  },
  methods: {
    handleChangeOne(files, fileList) {
      let jsono1 = [
        {
          "项目组__12__月份加班考勤表（加班至晚9点以后）": "客户简称：",
          列头2: "邮储行",
          列头3: "",
          列头4: "项目号：",
          列头5: "190777-53",
          列头6: "",
          列头7: "",
          列头8: "",
          列头9: "",
          列头10: "",
          列头11: "",
          列头12: "",
          列头13: "",
          列头14: "",
        },
        {
          "项目组__12__月份加班考勤表（加班至晚9点以后）": "客户简称：",
          列头2: "邮储行",
          列头3: "",
          列头4: "项目号：",
          列头5: "190777-53",
        },
        {
          "项目组__12__月份加班考勤表（加班至晚9点以后）": "客户简称：",
          列头2: "邮储行",
          列头3: "",
          列头4: "项目号：",
          列头5: "190777-53",
        },
        {
          "项目组__12__月份加班考勤表（加班至晚9点以后）": "项目经理签字",
          列头6: "分软经理签字",
          列头11: "客户签字",
        },
        {
          "项目组__12__月份加班考勤表（加班至晚9点以后）": "",
        },
        {
          "项目组__12__月份加班考勤表（加班至晚9点以后）": "日期",
          列头2: "星期",
          列头3: "合计人数",
          列头4: "合计金额",
          列头5: "加班人员名单",
        },
      ];
      console.log(files);
      console.log(files.name.split("#")[0]);
      console.log(fileList);
      this.projectNum = files.name.split("#")[0]; //获取项目编号

      jsono1[0].列头5 = this.projectNum; //修改jsono1项目编号
      jsono1[1].列头5 = this.projectNum; //修改jsono1项目编号
      jsono1[2].列头5 = this.projectNum; //修改jsono1项目编号
      const reader = new FileReader();
      reader.readAsArrayBuffer(files.raw);
      reader.onload = () => {
        const buffer = reader.result;
        const bytes = new Uint8Array(buffer);
        const length = bytes.byteLength;
        let binary = "";
        for (let i = 0; i < length; i++) {
          binary += String.fromCharCode(bytes[i]);
        }
        const wb = XLSX.read(binary, {
          type: "binary",
        });
        let outdata = XLSX.utils.sheet_to_json(wb.Sheets["XD软件序列考勤表"]);
        if(outdata == null || outdata == undefined  || outdata.length == 0){
          outdata = XLSX.utils.sheet_to_json(wb.Sheets["信贷与邮储事业部考勤表"]);
        }
        console.log(outdata)
        if(outdata.length == 0){
          this.$message.error('请检查sheets名称是否正确');
          return
        }
        this.data = [...outdata];
        //组装数据   [["2020-12-21","田晓旗","姜冬东", "aaa"] , [] , []]
        let wokingData = []; //本项目加班的人
        let WorkingCycle = this.WorkingCycle; //考勤周期
        for (let cIndex in WorkingCycle) {
          //初始化加班数据
          let aa = [
            WorkingCycle[cIndex],
            changeWeek(new Date(WorkingCycle[cIndex]).getDay()),
          ]; //"2020-12-01" 星期六
          wokingData.push(aa);
        }
        console.log(wokingData)
        //下载项目加班
        console.log(this.data);//工时表数据
        let gsColList = []; //工时表列名数组  ["__EMPTY", "__EMPTY_1", "__EMPTY_2"]
        let countTime = {}; //加班天数记录
        if (this.laterNumObj) {
          countTime = this.laterNumObj;
        }
        let ifexist = 0
        outdata.forEach((val, index) => {
          if (index == 0) {
            gsColList = Object.keys(val);
            console.log(gsColList)
          }
          // console.log(gsColList[0] == "__EMPTY" ? 0 : 1)
          if (index % 2 == (gsColList[0] == "__EMPTY" ? 0 : 1)&& index > 0) {
             //员工工时数据判断是否加班
                let nameNUm = val[`${gsColList[1]}`];
                // console.log(nameNUm)
                let nameList = nameNUm.split("-");
                let name = nameList[0];
                gsColList.forEach((gsVal, gsindex) => {
                  if (gsindex >= 2) {
                  // console.log(val[gsVal])
                    if (val[gsVal] >= 10) {
                      // console.log(gsindex - 2)
                      // console.log(wokingData[gsindex - 2])
                      if(wokingData[gsindex - 2] == undefined){
                        this.$message.error('考勤周期填写错了哦');
                      }
                      wokingData[gsindex - 2].push(name);
                      ifexist = 1
                      if (!countTime[name]) {
                        countTime[name] = 1;
                      } else {
                        countTime[name]++;
                      }
                    }
                  }
                });
          } 
          // if(gsColList[0] != "__EMPTY"){
          //       if (index % 2 == 1 && index > 0) {
                
          //       //员工工时数据判断是否加班
          //       let nameNUm = val[`${gsColList[1]}`];
          //       // console.log(nameNUm)
          //       let nameList = nameNUm.split("-");
          //       let name = nameList[0];
          //       gsColList.forEach((gsVal, gsindex) => {
          //         if (gsindex >= 2) {
          //         console.log(val[gsVal])
          //           if (val[gsVal] >= 10) {
          //             console.log(wokingData[gsindex - 2])
          //             wokingData[gsindex - 2].push(name);
          //             ifexist = 1
          //             if (!countTime[name]) {
          //               countTime[name] = 1;
          //             } else {
          //               countTime[name]++;
          //             }
          //           }
          //         }
          //       });
          //     }
          // }else{
          //   if (index % 2 == 0 && index > 0) {
            
          //   //员工工时数据判断是否加班
          //   let nameNUm = val[`${gsColList[1]}`];
          //   // console.log(nameNUm)
          //   let nameList = nameNUm.split("-");
          //   let name = nameList[0];
          //   gsColList.forEach((gsVal, gsindex) => {
          //     if (gsindex >= 2) {
          //      console.log(val[gsVal])
          //       if (val[gsVal] >= 10) {
          //         console.log(wokingData[gsindex - 2])
          //         wokingData[gsindex - 2].push(name);
          //         ifexist = 1
          //         if (!countTime[name]) {
          //           countTime[name] = 1;
          //         } else {
          //           countTime[name]++;
          //         }
          //       }
          //     }
          //   });
          // }
          // }
          
        });
        this.laterNumObj = countTime;
        console.log(wokingData);

        //if wokingData = null 本项目没有加班的人 判断if没有加班人员判断是否下载文件
     
        for (let d in wokingData) {
          //转化数据 0*3 + 8     8 11 14
          let line1 = {
            "项目组__12__月份加班考勤表（加班至晚9点以后）": wokingData[d][0],
            列头2: wokingData[d][1],
            列头3: `=COUNTA(E${d * 3 + 8}:N${d * 3 + 10})`,
            列头4: `=C${d * 3 + 8}*20`,
            列头5: wokingData[d][2],
            列头6: wokingData[d][3],
            列头7: wokingData[d][4],
            列头8: wokingData[d][5],
            列头9: wokingData[d][6],
            列头10: wokingData[d][7],
            列头11: wokingData[d][8],
            列头12: wokingData[d][9],
            列头13: wokingData[d][10],
            列头14: wokingData[d][11],
          };
          let line2 = {
            "项目组__12__月份加班考勤表（加班至晚9点以后）": wokingData[d][0],
            列头2: wokingData[d][1],
            列头3: "=COUNTA(E8:N10)",
            列头4: "=C8*20",
            列头5: wokingData[d][12],
            列头6: wokingData[d][13],
            列头7: wokingData[d][14],
            列头8: wokingData[d][15],
            列头9: wokingData[d][16],
            列头10: wokingData[d][17],
            列头11: wokingData[d][18],
            列头12: wokingData[d][19],
            列头13: wokingData[d][20],
            列头14: wokingData[d][21],
          };
          let line3 = {
            "项目组__12__月份加班考勤表（加班至晚9点以后）": wokingData[d][0],
            列头2: wokingData[d][1],
            列头3: "=COUNTA(E8:N10)",
            列头4: "=C8*20",
            列头5: wokingData[d][22],
            列头6: wokingData[d][23],
            列头7: wokingData[d][24],
            列头8: wokingData[d][25],
            列头9: wokingData[d][26],
            列头10: wokingData[d][27],
            列头11: wokingData[d][28],
            列头12: wokingData[d][29],
            列头13: wokingData[d][30],
            列头14: wokingData[d][31],
          };
          jsono1.push(line1);
          jsono1.push(line2);
          jsono1.push(line3);
        }
        console.log(jsono1);
        let aaaa = jsono1;
        if(ifexist == 0){
          console.log("0000000")
            this.$confirm('本项目没有加班的人, 是否下载文件?', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {
            //执行下面代码
            this.downloadExl(aaaa);
          }).catch(() => {
            //返回
            this.$message({
              type: 'info',
              message: '已取消下载'
            }); 
            return;         
          });
        }else{
          this.downloadExl(aaaa);
        }
        

        //生成汇总
        this.laterNum = []; //清除上次上传数据
        //组装页面显示数据  姓名   加班天数
        Object.keys(countTime).forEach((val, index) => {
          let element = { name: `${val}`, num: countTime[val] };
          this.laterNum.push(element);
        });
      
       
      };
    },
    handleRemove(file, fileList) {
      console.log(file, fileList);
    },
    handleExceed(files, fileList) {
      this.$message.warning(
        `当前限制选择 30 个文件，本次选择了 ${files.length} 个文件，共选择了 ${
          files.length + fileList.length
        } 个文件`
      );
    },
    beforeRemove(file, fileList) {
      return this.$confirm(`确定移除 ${file.name}？`);
    },
    setCurrent(row) {
      this.$refs.singleTable.setCurrentRow(row);
    },
    handleCurrentChange(val) {
      this.currentRow = val;
    },
    handleSelect() {},
    handleOne() {},
    handleChange(file, fileList) {
      console.log(file);
      console.log(fileList);
      const reader = new FileReader();
      reader.readAsArrayBuffer(file.raw);
      reader.onload = () => {
        const buffer = reader.result;
        const bytes = new Uint8Array(buffer);
        const length = bytes.byteLength;
        let binary = "";
        for (let i = 0; i < length; i++) {
          binary += String.fromCharCode(bytes[i]);
        }
        const wb = XLSX.read(binary, {
          type: "binary",
        });
        const outdata = XLSX.utils.sheet_to_json(wb.Sheets["考勤记录"]);
        this.data = [...outdata];
        console.log(outdata);

        let startdate = this.data[0].__EMPTY_1.split(" ~ ")[0]; //起始日期
        let enddate = this.data[0].__EMPTY_1.split(" ~ ")[1]; //结束日期
        //设置月份同步文件名称
        this.month = enddate.split("-")[1];
        console.log(enddate);//2021-01-20
        let dateArr = getAllDate(startdate, enddate); //考勤周期
        console.log(dateArr);

        this.WorkingCycle = dateArr; //考勤周期
        for (var f = 0; f < dateArr.length; f++) {
          let aa = [dateArr[f], new Date(dateArr[f]).getDay()]; //"2020-12-01" 星期六
          this.outList.push(aa);
        }
        console.log(this.outList);
        let step = 1;
        let list = []; //获取姓名集合
        this.data.map((v) => {
          if (v.__EMPTY_7 == "姓 名:") {
            list.push(step);
          }
          step = step + 1;
        });
        let dakaList = []; //获取打卡同事的index
        for (var i = 0; i < list.length; i++) {
          let j = i + 1;
          if (list[j] == list[i] + 1) {
            this;
          } else {
            dakaList.push(list[i]);
          }
        }
        //组装keys模板（）
        let keys = [];
        for (let dateAIndex = 0; dateAIndex < dateArr.length; dateAIndex++) {
          if (dateAIndex == 0) {
            keys.push("考 勤 记 录 表");
          }
          if (dateAIndex == 1) {
            keys.push("__EMPTY");
          } else if (dateAIndex > 1) {
            // console.log(dateAIndex - 1);
            keys.push(`__EMPTY_${dateAIndex - 1}`);
          }
        }
        console.log(keys);

        let workData = []; //打卡信息二维数组
        //处理打卡同事的数据 dakaList有记录的index
        for (var o = 0; o < dakaList.length; o++) {
          let index = 0;
          let val = []; //组装打卡信息 [name , time1 , time2]
          let name = this.data[dakaList[o] - 1].__EMPTY_9;
          val.push(name);
          val.push(this.data[dakaList[o]]); //打卡时间记录
          workData.push(val);
        }
        console.log(workData); //[[0: "陈昆容" ,1: {考 勤 记 录 表: "08:2917:44", __EMPTY: "18:27", __EMPTY_1: "08:1818:23", __EMPTY_2: "08:3018:02", __EMPTY_3: "08:2417:44", …}]]
        //记录加班次数
        let count = [];
        let countObj = {};
        //遍历 workData 判断是否加班
        for (let ind = 0; ind < workData.length; ind++) {
          let name = workData[ind][0]; //打卡人名称
          for (let key = 0; key < keys.length; key++) {
            let contime = workData[ind][1][keys[key]]; //获取时间
            let adudje = 0;

            //判断第二天00：01-08：30是否有打卡
            let nextContime = workData[ind][1][keys[key + 1]];

            console.log(keys[key + 1]);
            console.log(nextContime);
            //weiwan

            if (this.outList[key][1] == 0 || this.outList[key][1] == 6) {
              //如果是周六日
              if (contime != undefined) {
                adudje = daka.overtimeWeekend(contime);
              } else {
                adudje = 0;
              }
            } else {
              //周一---周五
              if (contime != undefined) {
                //判空
                adudje = daka.overtime(
                  contime,
                  this.value.split(":")[0] + this.value.split(":")[1]
                ); //判断函数
                if (adudje == 0 && nextContime != undefined) {
                  adudje = daka.dawn(nextContime);
                } //如果没有加班判断第二天凌晨有无打卡
              }
            }
            if (adudje == 1) {
              //获取名称
              this.outList[key].push(name);
              if (!countObj[name]) {
                countObj[name] = 1;
              } else {
                countObj[name]++;
              }
            }
          }
        }
        //组装页面显示数据  姓名   加班天数
        Object.keys(countObj).forEach((val, index) => {
          let element = { name: `${val}`, num: countObj[val] };
          this.tableData.push(element);
        });

        count.push([]);
        count.push([]);
        count.push([]);
        Object.keys(countObj).forEach((val, index) => {
          let element = {
            "项目组__12__月份加班考勤表（加班至晚9点以后）": "",
            列头2: "",
            列头3: "",
            列头4: "",
            列头5: "",
            列头6: `${index + 1}`,
            列头7: `${val}`,
            列头8: countObj[val],
            列头9: "",
            列头10: "",
            列头11: "",
            列头12: "",
            列头13: "",
            列头14: "",
          };
          console.log(element);

          count.push(element);
        });

        console.log(this.outList);
        // this.down(this.outList);
        //修改星期 时间格式
        for (let d in this.outList) {
          this.outList[d][1] = changeWeek(this.outList[d][1]);
        }
        //转化数据this.outList=> jsono
        console.log(jsono);

        //修改项目号

        for (let d in this.outList) {
          // if (this.outList[d].length > 50) {
          //   this.$message({
          //     message: "单个excle每天的加班人数不能超过50人",
          //     type: "warning",
          //   });
          //   return;
          // }
          //转化数据 0*3 + 8     8 11 14
          let line1 = {
            "项目组__12__月份加班考勤表（加班至晚9点以后）": this.outList[d][0],
            列头2: this.outList[d][1],
            列头3: `=COUNTA(E${d * 3 + 8}:N${d * 3 + 10})`,
            列头4: `=C${d * 3 + 8}*20`,
            列头5: this.outList[d][2],
            列头6: this.outList[d][3],
            列头7: this.outList[d][4],
            列头8: this.outList[d][5],
            列头9: this.outList[d][6],
            列头10: this.outList[d][7],
            列头11: this.outList[d][8],
            列头12: this.outList[d][9],
            列头13: this.outList[d][10],
            列头14: this.outList[d][11],
          };
          let line2 = {
            "项目组__12__月份加班考勤表（加班至晚9点以后）": this.outList[d][0],
            列头2: this.outList[d][1],
            列头3: "=COUNTA(E8:N10)",
            列头4: "=C8*20",
            列头5: this.outList[d][12],
            列头6: this.outList[d][13],
            列头7: this.outList[d][14],
            列头8: this.outList[d][15],
            列头9: this.outList[d][16],
            列头10: this.outList[d][17],
            列头11: this.outList[d][18],
            列头12: this.outList[d][19],
            列头13: this.outList[d][20],
            列头14: this.outList[d][21],
          };
          let line3 = {
            "项目组__12__月份加班考勤表（加班至晚9点以后）": this.outList[d][0],
            列头2: this.outList[d][1],
            列头3: "=COUNTA(E8:N10)",
            列头4: "=C8*20",
            列头5: this.outList[d][22],
            列头6: this.outList[d][23],
            列头7: this.outList[d][24],
            列头8: this.outList[d][25],
            列头9: this.outList[d][26],
            列头10: this.outList[d][27],
            列头11: this.outList[d][28],
            列头12: this.outList[d][29],
            列头13: this.outList[d][30],
            列头14: this.outList[d][31],
          };
          jsono.push(line1);
          jsono.push(line2);
          jsono.push(line3);
        }
        for (let as in count) {
          jsono.push(count[as]);
        }
        this.count = count;
        // jsono[]
        console.log(jsono);
        for (let jsonoindex in jsono) {
          if (jsonoindex > 6) {
            for (let v in jsono[jsonoindex]) {
              if (!jsono[jsonoindex][v]) {
                delete jsono[jsonoindex][v];
              }
            }
          }
        }
        console.log(jsono);
        this.jsono = jsono;
        // this.downloadExl(jsono);
      };
    },
    downloadExl(json, type) {
      var tmpdata = json[0];
      json.unshift({});
      var keyMap = []; //获取keys
      for (var k in tmpdata) {
        keyMap.push(k);
        json[0][k] = k;
      }
      var tmpdata = []; //用来保存转换好的json
      json
        .map((v, i) =>
          keyMap.map((k, j) =>
            Object.assign(
              {},
              {
                v: v[k],
                position:
                  (j > 25 ? this.getCharCol(j) : String.fromCharCode(65 + j)) +
                  (i + 1),
              }
            )
          )
        )
        .reduce((prev, next) => prev.concat(next))
        .forEach(
          (v, i) =>
            (tmpdata[v.position] = {
              v: v.v,
            })
        );

      var outputPos = Object.keys(tmpdata); //设置区域,比如表格从A1到D10
      console.log(tmpdata);
      //设置单元格合并
      for (let ad = 1; ad <= (json.length - 6) / 3; ad++) {
        let f1 = {
          s: {
            c: 0,
            r: (ad - 1) * 3 + 7,
          },
          e: {
            c: 0,
            r: (ad - 1) * 3 + 9,
          },
        };
        let f2 = {
          s: {
            c: 1,
            r: (ad - 1) * 3 + 7,
          },
          e: {
            c: 1,
            r: (ad - 1) * 3 + 9,
          },
        };
        let f3 = {
          s: {
            c: 2,
            r: (ad - 1) * 3 + 7,
          },
          e: {
            c: 2,
            r: (ad - 1) * 3 + 9,
          },
        };
        let f4 = {
          s: {
            c: 3,
            r: (ad - 1) * 3 + 7,
          },
          e: {
            c: 3,
            r: (ad - 1) * 3 + 9,
          },
        };
        style.merges.push(f1);
        style.merges.push(f2);
        style.merges.push(f3);
        style.merges.push(f4);
        //设置A8--D8样式
        tmpdata[`A${(ad - 1) * 3 + 8}`].s = style.font3;
        tmpdata[`B${(ad - 1) * 3 + 8}`].s = style.font3;
        tmpdata[`C${(ad - 1) * 3 + 8}`].s = style.font3;
        tmpdata[`D${(ad - 1) * 3 + 8}`].s = style.font3;
        //设置姓名区域样式
        let list = ["E", "F", "G", "H", "I", "J", "K", "L", "M", "N"];
        for (let indexList in list) {
          // console.log(tmpdata[`${list[indexList]}${(ad - 1) * 3 + 10}`]);

          tmpdata[`${list[indexList]}${(ad - 1) * 3 + 8}`].s = style.font4;
          tmpdata[`${list[indexList]}${(ad - 1) * 3 + 9}`].s = style.font4;
          if (tmpdata[`${list[indexList]}${(ad - 1) * 3 + 10}`]) {
            tmpdata[`${list[indexList]}${(ad - 1) * 3 + 10}`].s = style.font4;
          }
        }
      }
      tmpdata["!merges"] = style.merges; //设置单元格合并
      tmpdata["A1"].s = style.title;
      tmpdata["A4"].s = tmpdata["B4"].s = tmpdata["D4"].s = tmpdata["E4"].s =
        style.font1;
      tmpdata["A5"].s = tmpdata["F5"].s = tmpdata["K5"].s = style.font2;
      tmpdata["A7"].s = tmpdata["B7"].s = tmpdata["C7"].s = tmpdata[
        "D7"
      ].s = tmpdata["E7"].s = style.font3;
      console.log(tmpdata);

      var tmpWB = {
        SheetNames: ["加班餐费的具体加班几天名单"], //保存的表标题
        Sheets: {
          加班餐费的具体加班几天名单: Object.assign(
            {},
            tmpdata, //内容
            {
              "!ref": outputPos[0] + ":" + outputPos[outputPos.length - 1], //设置填充区域
            }
          ),
        },
      };
      var tmpDown = new Blob(
        [
          this.s2ab(
            XLSXStyle.write(
              tmpWB,
              {
                bookType: type == undefined ? "xlsx" : type,
                bookSST: false,
                type: "binary",
              } //这里的数据是用来定义导出的格式类型
            )
          ),
        ],
        {
          type: "",
        }
      );
      this.saveAs(tmpDown, this.filename);
    },
    getCharCol(n) {
      (s = ""), (m = 0);
      while (n > 0) {
        m = (n % 26) + 1;
        s = String.fromCharCode(m + 64) + s;
        n = (n - m) / 26;
      }
      return s;
    },
    s2ab(s) {
      if (typeof ArrayBuffer !== "undefined") {
        var buf = new ArrayBuffer(s.length);
        var view = new Uint8Array(buf);
        for (var i = 0; i != s.length; ++i) view[i] = s.charCodeAt(i) & 0xff;
        return buf;
      } else {
        var buf = new Array(s.length);
        for (var i = 0; i != s.length; ++i) buf[i] = s.charCodeAt(i) & 0xff;
        return buf;
      }
    },
    saveAs(obj, fileName) {
      var tmpa = document.createElement("a");
      tmpa.download = fileName || "下载";
      tmpa.href = URL.createObjectURL(obj);
      tmpa.click();
      setTimeout(function () {
        URL.revokeObjectURL(obj);
      }, 100);
    },
    ccc() {
      let a = { a: "asd", c: "dwaf", v: "adsfwe" };
      let b = { ss: "asdas", sf: "asdas", awdwss: "asdas" };
      a = b;

      console.log(a);
    },
  },
  watch:{
    value1:function(newQuestion){
      console.log(newQuestion)
      console.log("时间组件侦听器")
      this.WorkingCycle = getAllDate(newQuestion[0], newQuestion[1])//获取考勤周期
    }
  }
};
</script>
